package com.nulldev.util.data.Arrays.maps.trie;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

abstract class CNodeBase<K, V> extends MainNode<K, V> {

	@SuppressWarnings("rawtypes")
	private static final AtomicIntegerFieldUpdater<CNodeBase> UPDATER = AtomicIntegerFieldUpdater.newUpdater(CNodeBase.class, "csize");

	private volatile int csize = -1;

	public boolean CAS_SIZE(int oldval, int nval) {
		return UPDATER.compareAndSet(this, oldval, nval);
	}

	public void WRITE_SIZE(int nval) {
		UPDATER.set(this, nval);
	}

	public int READ_SIZE() {
		return csize;
	}

}